﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
using WmsApp.WindowControl;

namespace WmsApp.EntityControl
{
    public class EntityFilterByState
    {
        public static List<T> GetNeedSaveEntity<T>(List<T> list) where T : System.Data.Objects.DataClasses.EntityObject,WmsService.IWcfState
        {
            //var result = (from e in list
            //              let pi = e.GetType().GetProperty(Constant.WcfEntityStateName)
            //              let state = pi.GetValue(e, null)
            //              let es = (EntityState)state 
            //              where es == EntityState.Added || es == EntityState.Modified
            //              select e).ToList();
            //return result;

            var result = (from e in list
                          where e.WcfEntityState == EntityState.Added || e.WcfEntityState == EntityState.Modified
                          select e).ToList();
            return result;
        }
    }
}
